home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / DLLCust_Files / AXON / LINEARA.C < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  1.3 KB  |  44 lines

  1. // Dynamic link library implementation of NeuroSolutions BiasAxon component using the performAxon protocol
  2.  
  3. #include "NSDLL.h" 
  4.  
  5. /***********************************/
  6. /* Forward activation of component */
  7.  
  8. __declspec(dllexport) void performAxon(
  9.     DLLData *instance,    // Pointer to instance data
  10.     NSFloat    *data,         // Pointer to the layer of processing elements (PEs)
  11.     int     rows,        // Number of rows of PEs in the layer
  12.     int     cols        // Number of columns of PEs in the layer
  13.     )
  14. {
  15.     int i,length=rows*cols;
  16.     NSFloat *bias = getWeights(instance);
  17.     NSFloat beta = getFloatParameter(instance, 2, 1);
  18.  
  19.     for (i=0; i<length; i++)
  20.         data[i] = beta*data[i] + bias[i];
  21. }
  22.  
  23. /******************************************/
  24. /* Management of instance data (OPTIONAL) */
  25.  
  26. __declspec(dllexport) DLLData *allocAxon(
  27.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating
  28.     int     rows,            // Number of rows of PEs in the layer
  29.     int     cols            // Number of columns of PEs in the layer
  30.     )
  31. {
  32.     DLLData *instance = allocDLLInstance(oldInstance);
  33.     setParameterName(instance, 2, 1, "Beta", FALSE);
  34.     setFloatParameter(instance, 2, 1, 1.0f, FALSE);
  35.     setWeights(instance, rows*cols);
  36.     return instance;
  37. }
  38.  
  39. __declspec(dllexport) void freeAxon(DLLData *instance)
  40. {
  41.     freeDLLInstance(instance);
  42. }
  43.  
  44.